package com.ftg.learn.code.config;

import com.ftg.learn.code.properties.DyProperties;
import com.ftg.learn.code.utils.AliDyUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class DyConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public AliDyUtil aliDyUtil(DyProperties dyProperties) {
        log.info("开始创建阿里云短信服务对象：{}", dyProperties);
        return new AliDyUtil(dyProperties.getEndpoint(),
                dyProperties.getAccessKeyId(),
                dyProperties.getAccessKeySecret(),
                dyProperties.getSignName(),
                dyProperties.getTemplateCode()
        );
    }
}
